﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/2/7 20:08:36
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    /// <summary>
    /// 委托单
    /// </summary>
    [Table("Trusteeship")]
    public class Trusteeship : BaseEntity<Trusteeship>
    {
        private Trusteeship() { }
        public override Trusteeship Get(System.Linq.Expressions.Expression<Func<Trusteeship, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.Trusteeship.FirstOrDefault(where);
                if (item != null)
                {
                    this.AcceptDate = item.AcceptDate;
                    this.AgencyFee = item.AgencyFee;
                    this.Agent = item.Agent;
                    this.CloseOperator = item.CloseOperator;
                    this.CloseReason = item.CloseReason;
                    this.Contact = item.Contact;
                    this.Contract = item.Contract;
                    this.CustomerManager = item.CustomerManager;
                    this.Id = item.Id;
                    this.IsClose = item.IsClose;
                    this.IsOpen = item.IsOpen;
                    this.IsTrace = item.IsTrace;
                    this.Operator = item.Operator;
                    this.OrderId = item.OrderId;
                    this.PostDate = item.PostDate;
                    this.Receipt = item.Receipt;
                    this.RecruitId = item.RecruitId;
                    this.RequireDate = item.RequireDate;
                    return this;
                }
                return null;
            }
        }
        #region Fileds
        [Key]
        [Column("Id",TypeName="int")]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Column("OrderId",TypeName="varchar")]
        [StringLength(20)]
        public string OrderId { get; set; }

        /// <summary>
        /// 招募单Id
        /// </summary>
        [Required]
        [Column("RecruitId",TypeName="int")]
        public int RecruitId { get; set; }

        /// <summary>
        /// 提交日期
        /// </summary>
        [Required]
        [Column("PostDate",TypeName="datetime")]
        public DateTime PostDate { get; set; }

        /// <summary>
        /// 提交委托的代理人
        /// </summary>
        [Required]
        [Column("Agent",TypeName="varchar")]
        [StringLength(200)]
        public string Agent { get; set; }

        /// <summary>
        /// 委托约定
        /// </summary>
        [Column("Contract", TypeName = "nvarchar")]
        [StringLength(2000)]
        public string Contract { get; set; }

        /// <summary>
        /// 要求在多少时间前招募完成
        /// </summary>
        [Column("RequireDate",TypeName="datetime")]
        public DateTime RequireDate { get; set; }

        /// <summary>
        /// 代理人的线下联系方式
        /// </summary>
        [Required]
        [Column("Conatact",TypeName="nvarchar")]
        [StringLength(200)]
        public string Contact { get; set; }

        /// <summary>
        /// 是否已经开始线下跟进
        /// </summary>
        [Column("IsTrace",TypeName="bit")]
        public bool IsTrace { get; set; }

        /// <summary>
        /// 处理该委托的网站管理员
        /// </summary>
        [Column("Operator",TypeName="varchar")]
        public string Operator { get; set; }

        /// <summary>
        /// 网站管理员处理该委托的时间
        /// </summary>
        [Column("AcceptDate",TypeName="datetime")]
        public DateTime AcceptDate { get; set; }

        /// <summary>
        /// 是否已经达成一致并开始执行委托
        /// </summary>
        [Column("IsOpen",TypeName="bit")]
        public bool IsOpen { get; set; }

        /// <summary>
        /// 指派给的客户经理
        /// </summary>
        [Column("CustomerManager",TypeName="nvarchar")]
        [StringLength(45)]
        public string CustomerManager { get; set; }

        /// <summary>
        /// 是否已经结束该委托
        /// </summary>
        [Column("IsClose",TypeName="bit")]
        public bool IsClose { get; set; }

        /// <summary>
        /// 关闭该委托的操作员
        /// </summary>
        [Column("CloseOperator", TypeName="nvarchar")]
        [StringLength(200)]
        public string CloseOperator { get; set; }

        /// <summary>
        /// 关闭该委托的原因
        /// </summary>
        [Column("CloseReason",TypeName="nvarchar")]
        [StringLength(2000)]
        public string CloseReason { get; set; }

        /// <summary>
        /// 代理人回执
        /// </summary>
        [Column("Receipt",TypeName="nvarchar")]
        [StringLength(2000)]
        public string Receipt { get; set; }

        /// <summary>
        /// 到账的代理费
        /// </summary>
        [Column("AgencyFee",TypeName="decimal")]
        public decimal AgencyFee { get; set; }
        #endregion
    }
}
